const {
    Friendship
} = require("wechaty");
/**
 * 自动同意好友请求
 */
async function onFriendship(friendship) {
    const contact = friendship.contact()
    if (friendship.type() === Friendship.Type.Receive) { // 1. receive new friendship request from new contact
        let result = await friendship.accept()
        if (result) {
            console.log(`Request from ${contact.name()} is accept succesfully!`)
        } else {
            console.log(`Request from ${contact.name()} failed to accept!`)
        }
    } else if (friendship.type() === Friendship.Type.Confirm) { // 2. confirm friendship
        console.log(`New friendship confirmed with ${contact.name()}`)
    }
}
module.exports = onFriendship